import {CSSProperties} from "react";

export default class StyleUtils {


  static getCellStyle({backgroundColor, valueColor, vPadding, hPadding, margin}: Partial<{
    backgroundColor?: string;
    valueColor?: string;
    vPadding?: string;
    hPadding?: string;
    margin?: string;
  }> = {}): CSSProperties {
    const style: CSSProperties = {};

    if (backgroundColor !== undefined) {
      style['--cell-background-color'] = backgroundColor;
    }
    if (valueColor !== undefined) {
      style['--cell-value-color'] = valueColor;
    }
    if (vPadding !== undefined) {
      style['--cell-vertical-padding'] = vPadding;
    }
    if (hPadding !== undefined) {
      style['--cell-horizontal-padding'] = hPadding;
    }
    if (margin !== undefined) {
      style.margin = margin;
    }

    return style;
  }

  static getMiniCellStyle() {
    return {
      '--cell-vertical-padding': '5px',
    } as CSSProperties
  }
  static getMaxLines(lines: number = 2, additionalStyles?: CSSProperties): CSSProperties {
    // Core styles required for multi-line ellipsis
    const baseEllipsisStyles: CSSProperties = {
      overflow: 'hidden',
      textOverflow: 'ellipsis',
      display: '-webkit-box',
      WebkitLineClamp: lines,
      WebkitBoxOrient: 'vertical',
    };

    return {
      ...baseEllipsisStyles,
      ...(additionalStyles || {}), // Ensure we spread an object even if additionalStyles is null/undefined
    };
  }


  static getSwitchStyle(): CSSProperties {
    return {
      '--switch-width': `${8 * 6}px`,
      '--switch-height': `${8 * 3}px`,
      '--switch-node-size': `${8 * 3}px`,
    } as CSSProperties
  }

  static getEllipsisStyle({fontSize, lineHeight, actionFontSize, color}: Partial<{
    fontSize?: string;
    lineHeight?: string;
    actionFontSize?: string;
    color?: string;
  }> = {}): CSSProperties {
    const style: CSSProperties = {};

    if (fontSize !== undefined) {
      style['--ellipsis-font-size'] = fontSize;
    }
    if (lineHeight !== undefined) {
      style['--ellipsis-line-height'] = lineHeight;
    }
    if (actionFontSize !== undefined) {
      style['--ellipsis-action-font-size'] = actionFontSize;
    }
    if (color !== undefined) {
      style['--ellipsis-primary-color'] = color;
    }

    return style;
  }

  static getMiniEmptyStyle(): CSSProperties {
    return {
      '--empty-image-size': `100px`,
      '--empty-bottom-margin-top': `0px`,
      '--empty-description-line-height': `0px`,
      '--empty-description-padding': `0 0px`,
    } as CSSProperties
  }

  static getCircleStyle(): (string | CSSProperties) {
    return {
      backgroundColor: '#f00', borderRadius: '50%', color: '#fff', padding: '2px 3px'
    } as CSSProperties
  }

  static getBorderRadiusStyle(borderRadius): string | CSSProperties {
    return {
      borderRadius: borderRadius
    }
  }
}
